package com.deyuanyun.pic.ctrl.controller.dto;

import com.deyuanyun.pic.common.spring.SpringAppliction;
import com.deyuanyun.pic.common.util.StringUtils;
import com.deyuanyun.pic.ctrl.enumeration.ExinspDataStatedEnum;
import com.deyuanyun.pic.settings.controller.pipe.vo.PipeLocationDTO;
import com.deyuanyun.pic.settings.service.pipe.PipeLocationService;
import com.deyuanyun.pic.settings.support.utils.PipeDictUtils;

import java.util.Date;

/**
 *  外检项目扩展DTO
 *  @author axiao(xj08.dream@gmail.com)
 *  @date 2016-09-22
 *  @version 1.0
 *  Histroy: [修改人][时间][描述]
 */
public class ExinspTaskExpandDTO {

    private String id;

    /**
     * 管道编号
     */
    private String pipeLineId;

    /**
     * 管道名称
     */
    private String pipeLineName;

    /**
     * 起点编号
     */
    private String fromPointId;

    /**
     * 起点类型(桩、场站阀室)
     */
    private String fromPointType;

    /**
     * 起点绝对里程
     */
    public Long fromPointMileage;

    /**
     * 起点位置名称
     */
    private String fromName;

    /**
     * 终点编号
     */
    private String toPointId;

    /**
     * 终点类型(桩、场站阀室)
     */
    private String toPointType;

    /**
     * 终点绝对里程
     */
    public Long toPointMileage;

    /**
     * 终点位置名称
     */
    private String toName;

    /**
     * 项目名称
     */
    private String name;

    /**
     * 检测单位
     */
    private String testingCompany;

    /**
     * 检测日期_起
     */
    private Date testingDateFrom;

    /**
     * 检测日期_止
     */
    private Date testingDateTo;

    /**
     * 外检数据状态（NOT_IMPORT、IMPORTED）
     */
    private String exinspDataStated;

    /**
     * 检测内容_(阴保有效性|土壤腐蚀性|杂散电流干扰|涂层检测与评价)
     */
    private Short testContent;

    private boolean testContent0;

    private boolean testContent1;

    private boolean testContent2;

    private boolean testContent3;


    /**
     * 检测方法_(CIPS+DCVG | ACVG | 开挖检测 | 其它)
     */
    private Short testMethod;

    private boolean testMethod0;

    private boolean testMethod1;

    private boolean testMethod2;

    private boolean testMethod3;

    /**
     * 检测方法_其它（具体输入）
     */
    private String methodOther;

    /**
     * 备注
     */
    private String remarks;

    private String reportAttachmentId; //检测报告id

    private transient PipeLocationService pipeLocationService;

    public ExinspTaskExpandDTO() {
        pipeLocationService = SpringAppliction.getBean(PipeLocationService.class);
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getPipeLineId() {
        return pipeLineId;
    }

    public void setPipeLineId(String pipeLineId) {
        this.pipeLineId = pipeLineId;
    }

    public String getPipeLineName() {
        if(StringUtils.isNotEmpty(pipeLineId))
            return PipeDictUtils.getLineById(pipeLineId).getName();
        return pipeLineName;
    }

    public void setPipeLineName(String pipeLineName) {
        this.pipeLineName = pipeLineName;
    }

    public String getFromPointId() {
        return fromPointId;
    }

    public void setFromPointId(String fromPointId) {
        this.fromPointId = fromPointId;
    }

    public String getFromPointType() {
        return fromPointType;
    }

    public void setFromPointType(String fromPointType) {
        this.fromPointType = fromPointType;
    }

    public Long getFromPointMileage() {
        return fromPointMileage;
    }

    public void setFromPointMileage(Long fromPointMileage) {
        this.fromPointMileage = fromPointMileage;
    }

    public String getFromName() {
        if(StringUtils.isNotEmpty(fromPointId) && StringUtils.isNotEmpty(pipeLineId)) {
            PipeLocationDTO locationDTO  = pipeLocationService.queryPipeLocationById(pipeLineId, fromPointId);
            if(locationDTO != null)
                return locationDTO.getName();
        }
        return fromName;
    }

    public void setFromName(String fromName) {
        this.fromName = fromName;
    }

    public String getToPointId() {
        return toPointId;
    }

    public void setToPointId(String toPointId) {
        this.toPointId = toPointId;
    }

    public String getToPointType() {
        return toPointType;
    }

    public void setToPointType(String toPointType) {
        this.toPointType = toPointType;
    }

    public Long getToPointMileage() {
        return toPointMileage;
    }

    public void setToPointMileage(Long toPointMileage) {
        this.toPointMileage = toPointMileage;
    }

    public String getToName() {
        if(StringUtils.isNotEmpty(toPointId) && StringUtils.isNotEmpty(pipeLineId)) {
            PipeLocationDTO locationDTO  = pipeLocationService.queryPipeLocationById(pipeLineId, toPointId);
            if(locationDTO != null)
                return locationDTO.getName();
        }
        return toName;
    }

    public void setToName(String toName) {
        this.toName = toName;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getTestingCompany() {
        return testingCompany;
    }

    public void setTestingCompany(String testingCompany) {
        this.testingCompany = testingCompany;
    }

    public Date getTestingDateFrom() {
        return testingDateFrom;
    }

    public void setTestingDateFrom(Date testingDateFrom) {
        this.testingDateFrom = testingDateFrom;
    }

    public Date getTestingDateTo() {
        return testingDateTo;
    }

    public void setTestingDateTo(Date testingDateTo) {
        this.testingDateTo = testingDateTo;
    }

    public String getExinspDataStated() {
        return ExinspDataStatedEnum.getInstance(exinspDataStated).getLabel();
    }

    public void setExinspDataStated(String exinspDataStated) {
        this.exinspDataStated = exinspDataStated;
    }

    public Short getTestContent() {
        return testContent;
    }

    public void setTestContent(Short testContent) {
        this.testContent = testContent;
    }

    public boolean isTestContent0() {
        if(testContent != null)
            return (testContent >> 3 & 1) > 0 ? true : false;
        return testContent0;
    }

    public void setTestContent0(boolean testContent0) {
        this.testContent0 = testContent0;
    }

    public boolean isTestContent1() {
        if(testContent != null)
            return (testContent >> 2 & 1) > 0 ? true : false;
        return testContent1;
    }

    public void setTestContent1(boolean testContent1) {
        this.testContent1 = testContent1;
    }

    public boolean isTestContent2() {
        if(testContent != null)
            return (testContent >> 1 & 1) > 0 ? true : false;
        return testContent2;
    }

    public void setTestContent2(boolean testContent2) {
        this.testContent2 = testContent2;
    }

    public boolean isTestContent3() {
        if(testContent != null)
            return (testContent >> 0 & 1) > 0 ? true : false;
        return testContent3;
    }

    public void setTestContent3(boolean testContent3) {
        this.testContent3 = testContent3;
    }

    public Short getTestMethod() {
        return testMethod;
    }

    public void setTestMethod(Short testMethod) {
        this.testMethod = testMethod;
    }

    public boolean isTestMethod0() {
        if(testMethod != null)
            return (testMethod >> 3 & 1) > 0 ? true : false;
        return testMethod0;
    }

    public void setTestMethod0(boolean testMethod0) {
        this.testMethod0 = testMethod0;
    }

    public boolean isTestMethod1() {
        if(testMethod != null)
            return (testMethod >> 2 & 1) > 0 ? true : false;
        return testMethod1;
    }

    public void setTestMethod1(boolean testMethod1) {
        this.testMethod1 = testMethod1;
    }

    public boolean isTestMethod2() {
        if(testMethod != null)
            return (testMethod >> 1 & 1) > 0 ? true : false;
        return testMethod2;
    }

    public void setTestMethod2(boolean testMethod2) {
        this.testMethod2 = testMethod2;
    }

    public boolean isTestMethod3() {
        if(testMethod != null)
            return (testMethod >> 0 & 1) > 0 ? true : false;
        return testMethod3;
    }

    public void setTestMethod3(boolean testMethod3) {
        this.testMethod3 = testMethod3;
    }

    public String getMethodOther() {
        return methodOther;
    }

    public void setMethodOther(String methodOther) {
        this.methodOther = methodOther;
    }

    public String getRemarks() {
        return remarks;
    }

    public void setRemarks(String remarks) {
        this.remarks = remarks;
    }

    public String getReportAttachmentId() {
        return reportAttachmentId;
    }

    public void setReportAttachmentId(String reportAttachmentId) {
        this.reportAttachmentId = reportAttachmentId;
    }
}
